package com.lance.answer.question_export.gk_new;

import com.lance.answer.dto.GkUser;
import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.concurrent.LinkedBlockingDeque;

// 根据学生获取url
public class GetUserUrlInfo {

    public static void main(String[] args)  throws Exception{

        int sync = 16;
        String driverPath = null;

        LinkedBlockingDeque<GkUser> userQueue = new LinkedBlockingDeque<>();
        //    InputStream inputStream = new FileInputStream("libs//2022User.txt");
       //   String teacherName = "刘庆";
         // String teacherName = "刘";
       //   String teacherName = "李明";
          String teacherName = "朱晓玉";
      //  String teacherName = "李俊杰";
        InputStream inputStream = new FileInputStream("libs//teachers//"+teacherName+".user");
        List<String> users = IOUtils.readLines(inputStream, "utf-8");




        for(String u:users){
            String[] strs = u.split(",");
            String userCode = strs[0];
//            if(!Util.getVip().contains(userCode)){
//                continue;
//            }

            String pwd = "";
            if(strs[1].length()<18){
                pwd = strs[1];
            }else {
                pwd = strs[1].substring(6, 14);
                pwd = "Ouchn" + pwd;
            }
            GkUser gkUser = new GkUser(userCode,pwd,teacherName);
            userQueue.add(gkUser);
        }


        for (int i = 1; i <= sync; i++) {
            Thread answerThread = new GetUserUrlInfoTask(driverPath,userQueue);
            //log.info("加载课程ID：{} 名称：{} ", openCourseId,subjectName);
            answerThread.setName( "答题线程--" + i);
            answerThread.start();
        }

    }

}
